/*   1:    */ package com.atomikos.icatch.jta;
/*   2:    */ 
/*   3:    */ import com.atomikos.icatch.config.TSInitInfo;
/*   4:    */ import com.atomikos.icatch.config.UserTransactionService;
/*   5:    */ import com.atomikos.icatch.config.UserTransactionServiceImp;
/*   6:    */ import com.atomikos.util.SerializableObjectFactory;
/*   7:    */ import java.io.Serializable;
/*   8:    */ import javax.naming.NamingException;
/*   9:    */ import javax.naming.Reference;
/*  10:    */ import javax.naming.Referenceable;
/*  11:    */ import javax.transaction.HeuristicMixedException;
/*  12:    */ import javax.transaction.HeuristicRollbackException;
/*  13:    */ import javax.transaction.InvalidTransactionException;
/*  14:    */ import javax.transaction.NotSupportedException;
/*  15:    */ import javax.transaction.RollbackException;
/*  16:    */ import javax.transaction.SystemException;
/*  17:    */ import javax.transaction.Transaction;
/*  18:    */ import javax.transaction.TransactionManager;
/*  19:    */ import javax.transaction.UserTransaction;
/*  20:    */ 
/*  21:    */ public class UserTransactionManager
/*  22:    */   implements TransactionManager, Serializable, Referenceable, UserTransaction
/*  23:    */ {
/*  24:    */   private static final long serialVersionUID = -655789038710288096L;
/*  25:    */   private transient TransactionManagerImp tm;
/*  26:    */   private UserTransactionService uts;
/*  27:    */   private boolean forceShutdown;
/*  28:    */   private boolean startupTransactionService;
/*  29:    */   private boolean closed;
/*  30:    */   
/*  31:    */   private void checkSetup()
/*  32:    */     throws SystemException
/*  33:    */   {
/*  34: 78 */     if (this.closed) {
/*  35: 78 */       throw new SystemException("This UserTransactionManager instance was closed already. Call init() to reuse if desired.");
/*  36:    */     }
/*  37: 80 */     synchronized (TransactionManagerImp.class)
/*  38:    */     {
/*  39: 82 */       this.tm = ((TransactionManagerImp)TransactionManagerImp.getTransactionManager());
/*  40: 84 */       if (this.tm == null) {
/*  41: 87 */         if (getStartupTransactionService())
/*  42:    */         {
/*  43: 88 */           this.uts = new UserTransactionServiceImp();
/*  44: 89 */           TSInitInfo info = this.uts.createTSInitInfo();
/*  45: 90 */           this.uts.init(info);
/*  46: 91 */           this.tm = ((TransactionManagerImp)TransactionManagerImp.getTransactionManager());
/*  47:    */         }
/*  48:    */         else
/*  49:    */         {
/*  50: 95 */           throw new SystemException("Transaction service not running");
/*  51:    */         }
/*  52:    */       }
/*  53:    */     }
/*  54:    */   }
/*  55:    */   
/*  56:    */   public UserTransactionManager()
/*  57:    */   {
/*  58:104 */     this.startupTransactionService = true;
/*  59:105 */     this.closed = false;
/*  60:    */   }
/*  61:    */   
/*  62:    */   public void setStartupTransactionService(boolean startup)
/*  63:    */   {
/*  64:115 */     this.startupTransactionService = startup;
/*  65:    */   }
/*  66:    */   
/*  67:    */   public boolean getStartupTransactionService()
/*  68:    */   {
/*  69:125 */     return this.startupTransactionService;
/*  70:    */   }
/*  71:    */   
/*  72:    */   public void init()
/*  73:    */     throws SystemException
/*  74:    */   {
/*  75:139 */     this.closed = false;
/*  76:140 */     checkSetup();
/*  77:    */   }
/*  78:    */   
/*  79:    */   public void begin()
/*  80:    */     throws NotSupportedException, SystemException
/*  81:    */   {
/*  82:148 */     checkSetup();
/*  83:149 */     this.tm.begin();
/*  84:    */   }
/*  85:    */   
/*  86:    */   public boolean getForceShutdown()
/*  87:    */   {
/*  88:155 */     return this.forceShutdown;
/*  89:    */   }
/*  90:    */   
/*  91:    */   public void setForceShutdown(boolean value)
/*  92:    */   {
/*  93:164 */     this.forceShutdown = value;
/*  94:    */   }
/*  95:    */   
/*  96:    */   public void commit()
/*  97:    */     throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException
/*  98:    */   {
/*  99:174 */     checkSetup();
/* 100:175 */     this.tm.commit();
/* 101:    */   }
/* 102:    */   
/* 103:    */   public int getStatus()
/* 104:    */     throws SystemException
/* 105:    */   {
/* 106:184 */     checkSetup();
/* 107:185 */     return this.tm.getStatus();
/* 108:    */   }
/* 109:    */   
/* 110:    */   public Transaction getTransaction()
/* 111:    */     throws SystemException
/* 112:    */   {
/* 113:193 */     checkSetup();
/* 114:194 */     return this.tm.getTransaction();
/* 115:    */   }
/* 116:    */   
/* 117:    */   public void resume(Transaction tx)
/* 118:    */     throws InvalidTransactionException, IllegalStateException, SystemException
/* 119:    */   {
/* 120:203 */     checkSetup();
/* 121:204 */     this.tm.resume(tx);
/* 122:    */   }
/* 123:    */   
/* 124:    */   public void rollback()
/* 125:    */     throws IllegalStateException, SecurityException, SystemException
/* 126:    */   {
/* 127:214 */     checkSetup();
/* 128:215 */     this.tm.rollback();
/* 129:    */   }
/* 130:    */   
/* 131:    */   public void setRollbackOnly()
/* 132:    */     throws IllegalStateException, SystemException
/* 133:    */   {
/* 134:225 */     checkSetup();
/* 135:226 */     this.tm.setRollbackOnly();
/* 136:    */   }
/* 137:    */   
/* 138:    */   public void setTransactionTimeout(int secs)
/* 139:    */     throws SystemException
/* 140:    */   {
/* 141:235 */     checkSetup();
/* 142:236 */     this.tm.setTransactionTimeout(secs);
/* 143:    */   }
/* 144:    */   
/* 145:    */   public Transaction suspend()
/* 146:    */     throws SystemException
/* 147:    */   {
/* 148:245 */     checkSetup();
/* 149:246 */     return this.tm.suspend();
/* 150:    */   }
/* 151:    */   
/* 152:    */   public Reference getReference()
/* 153:    */     throws NamingException
/* 154:    */   {
/* 155:254 */     return SerializableObjectFactory.createReference(this);
/* 156:    */   }
/* 157:    */   
/* 158:    */   public void close()
/* 159:    */   {
/* 160:266 */     if (this.uts != null)
/* 161:    */     {
/* 162:267 */       this.uts.shutdown(this.forceShutdown);
/* 163:268 */       this.uts = null;
/* 164:    */     }
/* 165:270 */     this.closed = true;
/* 166:    */   }
/* 167:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\transactions-jta\3.7.0\transactions-jta-3.7.0.jar
 * Qualified Name:     com.atomikos.icatch.jta.UserTransactionManager
 * JD-Core Version:    0.7.0.1
 */